home *** CD-ROM | disk | FTP | other *** search
/ The World's Largest Collection of Windows Software / The World's Largest Collection of Windows Software - Disc 2.iso / win / pro171 / sample3d.c < prev    next >
C/C++ Source or Header  |  1992-11-17  |  3KB  |  113 lines

  1. //**************************************************************************
  2. //
  3. // Sample3D - Shows the use of CTL3D.DLL
  4. //
  5. // Yes it is really this easy.
  6. //
  7. //
  8. //**************************************************************************
  9.  
  10. #include <windows.h>
  11. #include <windowsx.h>
  12. #include <commdlg.h>
  13. #include "ctl3d.h"
  14.  
  15. extern const HINSTANCE _hInstance ;
  16. HWND hwndApp;
  17.  
  18. char szFilterSpec [128] =                       // file type filters
  19.              "Text Files (*.TXT)\0*.TXT\0All Files (*.*)\0*.*\0";
  20.  
  21. char szFileName[120];
  22.  
  23. BOOL FAR PASCAL OpenHook(HWND hwnd, int wm, int wParam, long lParam)
  24. {
  25.     switch (wm) {
  26.     case WM_INITDIALOG:
  27.             // We must call this to subclass the directory listbox even
  28.             // if the app calls Ctl3dAutoSubclass (commdlg bug)
  29.             Ctl3dSubclassDlg(hwnd, CTL3D_ALL);
  30.         break;
  31.     }
  32.     return FALSE;
  33. }
  34.  
  35.  
  36. void FileOpen(HWND hwndOwner)
  37. {
  38.     OPENFILENAME ofn;
  39.  
  40.     /* fill in non-variant fields of OPENFILENAME struct. */
  41.     ofn.lStructSize       = sizeof(OPENFILENAME);
  42.     ofn.hwndOwner      = hwndOwner;
  43.     ofn.lpstrFilter      = szFilterSpec;
  44.     ofn.lpstrCustomFilter = NULL;
  45.     ofn.nMaxCustFilter      = 0;
  46.     ofn.nFilterIndex      = 1;
  47.     ofn.lpstrFile         = szFileName;
  48.     ofn.nMaxFile      = 120;
  49.     ofn.lpstrInitialDir   = NULL;
  50.     ofn.lpstrFileTitle    = NULL;
  51.     ofn.nMaxFileTitle     = 120;
  52.     ofn.lpstrTitle        = "3D Look";
  53.     ofn.lpstrDefExt       = "TXT";
  54.     ofn.Flags = OFN_HIDEREADONLY | OFN_ENABLEHOOK;
  55.          ofn.lpfnHook = MakeProcInstance(OpenHook, _hInstance);
  56.     ofn.lCustData = 0;
  57.     ofn.lpTemplateName = 0;
  58.  
  59.     GetOpenFileName ((LPOPENFILENAME)&ofn);
  60.     FreeProcInstance(ofn.lpfnHook);
  61. }
  62.  
  63.  
  64. //
  65. // Dialog Procedure
  66. //
  67. BOOL FAR PASCAL DialogProc(HWND hdlg, UINT wm, WPARAM wParam, LPARAM lParam)
  68. {
  69.     switch(wm) {
  70.     default:
  71.             return FALSE;
  72.  
  73.         case WM_SYSCOLORCHANGE:
  74.            Ctl3dColorChange();
  75.            break;
  76.  
  77.     case WM_COMMAND:
  78.             if (wParam == IDOK) {
  79.                 EndDialog(hdlg, TRUE);
  80.             }
  81.             else if (wParam == 130 ) {
  82.                 MessageBox(hdlg, "This is a sample Message Box","3D Look", MB_OK);
  83.             }
  84.             else if (wParam == 131 ) {
  85.                 FileOpen(hdlg);
  86.             }
  87.             break;
  88.     }
  89.  
  90.     return TRUE;
  91. }
  92.  
  93.  
  94.  
  95.  
  96. //
  97. // This sample uses main() instead of WinMain
  98. //
  99. void main( int argc, char *argv[], char **envp )
  100. {
  101.    FARPROC lpproc;
  102.  
  103.    Ctl3dRegister(_hInstance);
  104.    Ctl3dAutoSubclass(_hInstance);
  105.  
  106.    lpproc = MakeProcInstance((FARPROC) DialogProc, _hInstance);
  107.    DialogBox(_hInstance, MAKEINTRESOURCE(100), NULL, lpproc);
  108.    FreeProcInstance(lpproc);
  109.  
  110.    Ctl3dUnregister(_hInstance);
  111.    return;
  112. }
  113.